/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.knolle.lotes.utilidades;

import java.beans.IntrospectionException;
import java.util.List;
import modelo.Lotes;
import org.openide.nodes.BeanNode;
import org.openide.nodes.Node;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children;
import org.openide.util.Exceptions;
import org.openide.util.lookup.Lookups;

/**
 *
 * @author marcelo
 */
public class LotesChildFactory extends ChildFactory<Lotes> {

    private List<Lotes> resultList;

    public LotesChildFactory(List<Lotes> resultList) {
        this.resultList = resultList;
    }

    @Override
    protected boolean createKeys(List<Lotes> list) {
        for (Lotes lotes : resultList) {
            list.add(lotes);
        }
        return true;
    }

    @Override
    protected Node createNodeForKey(Lotes l) {
        try {
            return new LotesBeanNode(l);
        } catch (IntrospectionException ex) {
            Exceptions.printStackTrace(ex);
            return null;
        }
    }
    
    private class LotesBeanNode extends BeanNode {
    public LotesBeanNode(Lotes bean) throws IntrospectionException {
        super(bean, Children.LEAF, Lookups.singleton(bean));
    }
}

}